package XYC;

import static org.junit.Assert.assertTrue;
import org.junit.Test;
import java.awt.geom.Point2D;
/**
 * Test the functionality for method computeHeading in RoboCodeUtil.
 * @author Yichi Xu.
 * */
public class TestMethodComputeHeading {

  /**
   * Test the functionality for method computeHeading in RoboCodeUtil
   * Make sure computed heading for moving from (1,1) to (2,2) is 45 degree.
   */
  @Test
  public void testComputeHeading () {
    Point2D p1 = new Point2D.Double(2,2);
    Point2D p2 = new Point2D.Double(1,1);
    double currentHeading = 0;
    assertTrue("Check the method computeHeading ", 
        Math.abs(RoboCodeUtil.computeHeading(p1,p2,currentHeading) - 45) < 1 ); 
  }
}
